/*
 * @Author: 空1 1765027130@qq.com
 * @Date: 2025-02-08 13:56:59
 * @LastEditors: 空1 1765027130@qq.com
 * @LastEditTime: 2025-02-27 11:04:15
 * @FilePath: \rh_home\public\assets\js\backend\dashboard.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template', 'echarts-map-china','bootstrap-daterangepicker','moment',], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template, EchartsMapChina, undefined, undefined) {

    var Controller = {
        index: function () {

        
        






            //员工分析
            var myUserChart = Echarts.init(document.getElementById('user'));
            var userOption = {
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['入职', '转正', '离职'],
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '10%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    //data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                    data:Config.column,
                    axisLabel: {
                        interval: 0, // 强制显示所有标签
                        // rotate: 30  // 旋转标签，防止过长
                    }
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '入职',
                        type: 'line',
                        smooth: true,
                        ///data: [120, 132, 101, 134, 90, 230, 210, 100, 50, 30, 15, 38],
                        data:Config.staffdata1,
                        itemStyle: {
                            color: '#6aae6d' // 自定义颜色
                        },
                        areaStyle: {
                            color: '#deedde' // 背景色
                        }
                    },
                    {
                        name: '转正',
                        type: 'line',
                        smooth: true,
                        //data: [120, 132, 101, 134, 90, 230, 210, 100, 50, 30, 15, 38],
                        data:Config.staffdata2,
                        itemStyle: {
                            color: '#9cd1d8' // 自定义颜色
                        },
                        areaStyle: {
                            color: '#e1f1f3' // 背景色
                        }
                    },
                    {
                        name: '离职',
                        type: 'line',
                        smooth: true,
                       // data: [11, 12, 10, 14, 80, 250, 20, 150, 50, 300, 150, 15],
                       data:Config.staffdata3,
                        itemStyle: {
                            color: '#84abf1' // 自定义颜色
                        },
                        areaStyle: {
                            color: '#dce7fb' // 背景色
                        }
                    }
                ]
            };
            myUserChart.setOption(userOption);
            //员工数据
            var mySaleChart = Echarts.init(document.getElementById('sale'));
            var saleOption = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    data: ['升职', '调入', '调出'],
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '10%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                   // data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                   data:Config.column,
                    axisLabel: {
                        interval: 0, // 强制显示所有标签
                        // rotate: 30  // 旋转标签，防止过长
                    }
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '升职',
                        type: 'bar',
                        data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                        itemStyle: {
                            color: '#2478f2'
                        }
                    },
                    {
                        name: '调入',
                        type: 'bar',
                        data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                        itemStyle: {
                            color: '#84b7f9'
                        }
                    },
                    {
                        name: '调出',
                        type: 'bar',
                        data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                        itemStyle: {
                            color: '#5f9cf8'
                        }
                    }
                ]
            };
            mySaleChart.setOption(saleOption);

         //开卡充值
         var myCardChart = Echarts.init(document.getElementById('attendance'));
         var cardOption  = {
             color: ['#4f86eb', '#68bbc4', '#57a45b', '#96CEB4', '#FFEEAD'],
             tooltip: {
                 trigger: 'item', // 或 'axis'
                 axisPointer: { type: 'shadow' } // 坐标轴指示器样式
             },
             legend: {
                 orient: 'vertical',
                 left: '10%',
                 top: '20%',        // 标题下方20%位置
                 itemGap: 20,
                 textStyle: {
                     color: '#666'
                 }
             },
             series: [{
                 type: 'pie',
                 radius: ['40%', '70%'],
                 center: ['60%', '50%'],
                 label: { show: false },
                 labelLine: { show: false },
                //  data: [
                //      { value: 2225.00, name: '考勤正常' },
                //      { value: 0, name: '考勤异常' },
                //  ],
                data: Config.staffdata,
             }]
         };
         myCardChart.setOption(cardOption);


            $(document).on("click", ".btn-refresh", function () {
                setTimeout(function () {
                    myChart.resize();
                }, 0);
            });

        }
    };

    return Controller;
});
